package c.x.jy.service.redis;

import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;

 
@SuppressWarnings("all")
public class RedisCacheImpl implements Cache {
	protected static Logger logger = LoggerFactory.getLogger(RedisCacheImpl.class);
    @Override
    public String get(String Cache, String key) {
        return RedisUtils.redisUtils.get(Cache+":"+key);
    }

    
    @Override
    public Object get(String Cache, String key,Class<?> c) {
        return RedisUtils.redisUtils.get(Cache+":"+key,c);
    }
    @Override
    public void put(String Cache, String key, Object value,int time) {
    	RedisUtils.redisUtils.set (Cache+":"+key,value,time);
    }

	@Override
	public void remove(String Cache,String key) {
		RedisUtils.redisUtils.delete(Cache+":"+key);
		//JedisUtil.delObject(Cache+":"+key);
		//JedisUtil.del(ObjectUtil.serialize(Cache+":"+key));
	}

	@Override
	public Long generateLongKey(String key) {
	
		return RedisUtils.redisUtils.setIncr(key, 1l);
	}


	@Override
	public String get(String key) {
		// TODO Auto-generated method stub
	    return RedisUtils.redisUtils.get( key);
	}
 
/**
 * 时间秒
 */
	@Override
	public void set(String key ,Object value,Long expire) {
		// TODO Auto-generated method stub
	 
		  RedisUtils.redisUtils.set(key, value, expire );;
	}


	@Override
	public Object get(String key, Class<?> class1) {
		// TODO Auto-generated method stub
		return  JSON.parseObject(   get(key),class1);
	}


	@Override
	public void remove(String key) {
		// TODO Auto-generated method stub
		RedisUtils.redisUtils.delete(key);
	}


	@Override
	public Integer getSize(String cache) {
		// TODO Auto-generated method stub
		return RedisUtils.redisUtils.keys(cache).size();
	}
	@Override
	public Set<String> keys(String key){
		return RedisUtils.redisUtils.keys(key);
	}


	@Override
	public void remove(Set<String> keys) {
		for (String key : keys) {
			RedisUtils.redisUtils.delete(key);
		}
	}
 
 
}
